Xbasic

= (Equals Operator)

Syntax

Result as L = Operand1 as A = Operand2 as A

Arguments

Operand1Any Type

In comparison operations, a value or expression of any type. In assignmenet operations, the name of a variable.

Operand2Any Type

A value or expression of any type. In comparison opeartions, the value to compare to Operand1. In assignment operations, the value to set in the variable specified as Operand1.

Description

The Equals operator returns .T. (TRUE) if both Operand1 and Operand2 are of the same type and have the same value, i.e. if the expressions on both sides of the operator are equal.

Discussion

When comparing character strings, the Equals operator removes trailing white space and does a case-insensitive comparison. For case-sensitive comparisons that include white space, use the Exactly Matching Operator.

You cannot assign the values of a pointer (or dot) variable by using the equals operator. This causes only the addresses of the two pointers to be equal. Use PROPERTY_RECURSE_ASSIGN() to assign the values of one pointer variable to another pointer variable.

Example: Mathematical Assignment

The variable receiving the results of a mathematical calculation is always to the left side of the equals operator.

dim vNum as N
vNum = 5 * 6

? vNum
= 30

vNum = (5 * 6) / (5 - 6) * -1

? vNum
= 30

Example: Testing Equality

The following tests of equal were done in the Interactive Window.

dim equal as L
equal = 1 = 2
? equal
= .F.

equal = "alpha" = "alpha"
? equal
= .T.

? 2 = 3 
= .F.

dim QTY as N
QTY = 10

? QTY = 10
= .T.

dim STARTDATE as D
STARTDATE = {12/18/95}

? STARTDATE = CTOD("12/18/95")
= .T.

? DATE()
= {03/04/2017}

? STARTDATE = DATE()
= .F.

dim STATE as C
STATE = "MA"

? STATE = "MA"
= .T.

dim LASTNAME as C
LASTNAME = "Kalil"

? LASTNAME = "Ciaccio"
= .F.

? "Foley " = "foley    "
= .T.

? "fish" = "Fishman"
= .F.

See Also